//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for SageMaker
public struct SageMakerErrorType: AWSErrorType {
    enum Code: String {
        case conflictException = "ConflictException"
        case resourceInUse = "ResourceInUse"
        case resourceLimitExceeded = "ResourceLimitExceeded"
        case resourceNotFound = "ResourceNotFound"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize SageMaker
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// There was a conflict when you attempted to modify an experiment, trial, or trial component.
    public static var conflictException: Self { .init(.conflictException) }
    /// Resource being accessed is in use.
    public static var resourceInUse: Self { .init(.resourceInUse) }
    ///  You have exceeded an Amazon SageMaker resource limit. For example, you might have too many training jobs created.
    public static var resourceLimitExceeded: Self { .init(.resourceLimitExceeded) }
    /// Resource being access is not found.
    public static var resourceNotFound: Self { .init(.resourceNotFound) }
}

extension SageMakerErrorType: Equatable {
    public static func == (lhs: SageMakerErrorType, rhs: SageMakerErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension SageMakerErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
